<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
    <title>芳小微宣</title>
    <!-- 引入 WeUI -->
    <link rel="stylesheet" href="http://res.wx.qq.com/open/libs/weui/0.4.0/weui.min.css">
    <link rel="stylesheet" href="css/index.css">
    <script src="js/jquery.min.js"> </script>
    <script src="js/index.js"></script>
    <style>
        iframe{
            border: 0;
        }
        .titleName{
            text-align: center;
            font-size: 5.2rem;
        /* margin-top: 10px; */
            border-bottom: 1px solid #cccccc;
            height: 50px;
            line-height: 50px;
        }
        .imgSin{
            width: 100%;
            margin: 0;
            border-bottom: 1px solid #ebebeb;
            background: #fff;
        }
        .wordSin{
            background: #fff;
        }
        .yuyue{
            font-size: 4.8rem;
            position: relative;
            bottom: 13px;
        }
        .selSty{
            margin-left: 0;
            width: 50%;
        }
        .datesty{
            width: 50%;
            height: 35px;
            margin-top: 1rem;
            background: #ededed;
            border: 0;
            border-radius: 5px;
            font-size: 4.8rem;
            text-indent: 7px;
        }
    </style>
</head>
<body>
<div class="weui_cells_title">基地预约</div>
    <div class="content">
        <div class="imgSin">
            <a>
                <div class="Photo_left"><img src="images/address.png"/></div>
                <div class="Photo_right">
                    <span class="wordSin" style="padding-top: 8px;width: 85px;color: #a0a0a0;font-size: 4.8rem">基地名称</span>
                    <soan class="yuyue yuyueName"></soan>
                </div>
            </a>
        </div>
        <div class="imgSin">
            <a>
                <div class="Photo_left"><img src="images/people.png"/></div>
                <div class="Photo_right">
                    <span class="wordSin" style="padding-top: 8px;width: 85px;color: #a0a0a0;font-size: 4.8rem">预约人</span>
                    <soan class="yuyue yuyuePerson"></soan>
                </div>
            </a>
        </div>
        <div class="imgSin">
            <a>
                <div class="Photo_left"><img src="images/classimg.png"/></div>
                <div class="Photo_right">
                    <span class="wordSin" style="padding-top: 8px;width: 85px;color: #a0a0a0;font-size: 4.8rem">预约班级</span>
                    <soan class="yuyue">
                        <select class="selSty classMc">
                            <option>请选择</option>
                        </select>
                    </soan>
                </div>
            </a>
        </div>
        <div class="imgSin">
            <a>
                <div class="Photo_left"><img src="images/time.png"/></div>
                <div class="Photo_right">
                    <span class="wordSin" style="padding-top: 8px;width: 85px;color: #a0a0a0;font-size: 4.8rem">预约时间</span>
                    <span class="yuyue"><input type="date" class="datesty"/> </span>
                </div>
            </a>
        </div>
    </div>

<div class="btnChoose">
    <div id="returnIndex">
        <img src="images/return.png" style="width: 25px;padding-top: 5px;"><br>
        <span>返回</span>
    </div>
    <div style="visibility: hidden;">
        <img src="images/add.png" id="addNew" style="width: 55px;position: relative;top: -12px;">
    </div>
    <div id="order">
        <img src="images/submit.png" style="width: 25px;padding-top: 5px;"><br>
        <span>预约</span>
    </div>
</div>
<div class="weui_dialog_alert" style="display: none;">
    <div class="weui_mask"></div>
    <div class="weui_dialog">
        <div class="weui_dialog_hd"> <strong class="weui_dialog_title">警告</strong>
        </div>
        <div class="weui_dialog_bd">弹窗内容，告知当前页面信息等</div>
        <div class="weui_dialog_ft">
            <a href="javascript:;" class="weui_btn_dialog primary">确定</a>
        </div>
    </div>
</div>
<script>
    $.weui = {};
    $.weui.alert = function(options,sureEvent){
        options = $.extend({title: '提示', text: '提示内容'}, options);
        var $alert = $('.weui_dialog_alert');
        $alert.find('.weui_dialog_title').text(options.title);
        $alert.find('.weui_dialog_bd').text(options.text);
        $alert.on('touchend click', '.weui_btn_dialog', function(event){
            $alert.hide();
            if(sureEvent){
                sureEvent();
            }
            //阻止事件冒泡
            // event.stopPropagation();
            return false;
        });
        $(".weui_mask").click(function(){
            $alert.hide();
        });
        $alert.show();
    };
$(function(){
    $.ajax({
        type : "POST",
        url : path + "/api/weixin/getClassBySchool?token=" + window.localStorage.getItem("token"),
        data : {},
        dataType : 'json',
        async : true,
        success : function(msg) {
            if(msg.code == 0){
                var imghtml = "";
                for(var i=0;i<msg.classList.length;i++){
                    imghtml += '<option value="'+ msg.classList[i].classId +'">'+ msg.classList[i].className +'</option>';
                }
                $(".classMc").append(imghtml);
                $(".classMc").find("option").eq(1).attr("selected",'selected');
                $(".classMc").change();
            }else if(msg.code == 501){
                window.location.href = "login.html";
            }
        }
    });
    $(".yuyueName").html(decodeURI(getParam("eduname")));
    $(".yuyuePerson").html(window.localStorage.getItem("username"));
});
        $("#returnIndex").click(function(){
            window.location.href = "jdList.html";
        });
        $("#order").click(function(){
            if($(".classMc").val() == "请选择"){
                $.weui.alert({text: "请选择预约班级！"});
            }else if($(".datesty").val() == ""){
                $.weui.alert({text: "请选择时间！"});
            }else{
                $.ajax({
                    type : "POST",
                    url : path + "/api/weixin/addEduAppt",
                    data : {
                        "token" : window.localStorage.getItem("token"),
                        "eduId" : getParam("id"),
                        "classId" : $(".classMc").val(),
                        "apptDate" : $(".datesty").val()
                    },
                    dataType : 'json',
                    success : function(msg) {
                        if(msg.code == 0){
                            window.location.href = "jdList.html";
                        }else if(msg.code == 500){
                            $.weui.alert({text: "重复预约！"});
                        }else if(msg.code == 501){
                            window.location.href = "login.html";
                        }
                    }
                });
            }
        });
</script>
</body>
</html>